//
//  GamePlayLayer.h
//  MathSpeed
//
//  Created by ToanTM on 5/16/14.
//
//

#ifndef __MathSpeed__GamePlayLayer__
#define __MathSpeed__GamePlayLayer__

#include <iostream>
#include <cocos2d.h>
#include "MathObj.h"
#include "GameMode.h"
#include "GameOverLayer.h"

USING_NS_CC;

class GamePlayLayer : public CCLayer {
    typedef enum {
        REPLAY, GO_TO_MENU
    }NextActionOfGameOverLayer;
public:
    
private:
    GameMode::GamePlayMode mGameMode;
    CCMenuItemSprite* mBtnCancel;
    CCMenuItemSprite* mBtnOk;
    CCLabelTTF *mLbScore, *mLbHighScore;
    MathObj* mMatchObj;
    CCLabelTTF *mLbPrLeft, *mLbPrRight, *mLbMatchOperator, *mLbResult;
    GameOverLayer* mGameOverLayer;
    int mScore, mHighScore;
    NextActionOfGameOverLayer mNextActionOfGameOverLayer;
    CCSprite *mSpBar;
    bool mIsFirstTime;
    // method
    const char* getStringForScore();
    const char* getStringForHightScore();
    void updateScreenPlay();
    void checkResult(bool answer);
    void showGameOverLayer();
    void hideGameOverLayer();
    CCString* getStringOfGameMode();
    void gameOver();
public:

    // method
    virtual bool init();
    static CCScene* scene(GameMode::GamePlayMode mode);
    CREATE_FUNC(GamePlayLayer);
    static GamePlayLayer* createWithGameMode(GameMode::GamePlayMode mode);
    
    void setGameMode(GameMode::GamePlayMode mode);
    void buttonCancelCallback(CCObject* sender);
    void buttonOkCallback(CCObject* sender);
    void buttonPlayCallback(CCObject* sender);
    void buttonMenuCallback(CCObject* sender);
    void gameOverLayerExitDone();
    void keyBackClicked(void);
    void timeOver();
};

#endif /* defined(__MathSpeed__GamePlayLayer__) */
